import pandas as pd
import math

als_data = pd.read_csv('als_rating.csv')
print(als_data.head())
rsvd_data = pd.read_csv('rating.csv')
print(rsvd_data.head())

data = pd.merge(als_data, rsvd_data, on = ['userid','movieid'])
print(data.head())
print(len(data))

als_rmse = 0
rsvd_rmse = 0
als_bubi_rmse = 0
for i in range(len(data)):
    als_score = data['als_score'][i]
    rsvd_score = data['rating'][i]
    als_bubi_score = data['ALS_bubi'][i]
    ora_score = data['ora_rating'][i]
    als_rmse += math.pow(als_score - ora_score, 2)
    rsvd_rmse += math.pow(rsvd_score - ora_score, 2)
    als_bubi_rmse += math.pow(als_bubi_score - ora_score, 2)

print("ALS - Rmse:",als_rmse/len(data))
print("RSVD - Rmse:",rsvd_rmse/len(data))
print("ALS add bubi - Rmse:",als_bubi_rmse/len(data))